import { Button } from "antd-mobile";
import * as React from "react";
import { useBanner } from "../../store/banner";
import { useCounter } from "../../store/counter";

export interface ICompBProps {}

export default function CompB(props: ICompBProps) {
  const { increment } = useCounter((state) => state);
  const { banner, fetchBanner, addBanner } = useBanner((state) => state);
  React.useEffect(() => {
    if (!banner.length) {
      fetchBanner();
    }
  }, []);
  return (
    <div className="box">
      <h1>CompB</h1>
      <Button
        color="primary"
        onClick={() => {
          increment(5);
        }}
      >
        按钮
      </Button>
      <Button
        color="success"
        onClick={() => {
          addBanner({
            objectId: Math.random() + "",
            name: "新banner",
            music: "",
            img: "https://file2204.h5project.cn/sEHqreOKSBTx2IiaFIRHfilzae7vw9cb/banner2.webp",
          });
        }}
      >
        新增banner数据
      </Button>
    </div>
  );
}
